from ..bot_plugin import Bot_plugin
from cqhttp import CQHttp
from bot_body import Bot_body
import logging
import colorful

class Plugin_protect(Bot_plugin):
    def __init__(self, bot_body: Bot_body, proctectees=[892132762, 1215002199], name="Protector"):
        Bot_plugin.__init__(self, bot_body, name=name)
        self.protectees = proctectees
        self.help_msg="【禁言保护助手帮助】"

    def register_all(self):
        self.register('notice')

    def handle_notice(self, context):
        if 'sub_type' in context and context['sub_type'] == 'ban':
            if context['user_id'] in self.protectees:
                self.bot.set_group_ban(group_id = context['group_id'],
                    user_id = context['user_id'],
                    duration=0
                )
            